<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
</head>

<body>
  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">
    <div class="panel panel-default x-panel x-panel-layout">
      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/user">用户管理</a></li>
          <li class="active">用户管理</li>
        </ol>
      </div>

      <div class="panel-body">
        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">
          <form id="inbody-report-form" class="form-horizontal" method="GET" action="${ctx.host}/satisfaction-survey-create/search">
            <div class="x-breadcrumb-wrapper">
              <div class="x-breadcrumb clearfix">
                <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>满意度调查&nbsp;-&nbsp;选择调查学员</span></h2>
                <div class="pull-right">
                  <select name="siteId" class="select2">
                    <option value="">所有门店</option>
                    <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                      <option value="${site.id}" ${site.id == siteId ? 'selected' : ''}>${site.name}</option>
                    </c:forEach>
                  </select>
                </div>
              </div>
            </div>

            <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
              <div class="form-group x-form-group">
                <!-- <label class="col-xs-2 control-label">门店</label>
                <div class="col-xs-3" style="width: 30%;">
                  <select name="siteId">
                    <option value="">所有门店&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
                    <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                      <c:if test="${!site.disabled}">
                        <option value="${site.id}" ${site.id == siteId ? 'selected' : ''}>${site.name}</option>
                      </c:if>
                    </c:forEach>
                  </select>
                </div> -->
                <label class="col-xs-2 control-label">主教练</label>
                <div class="col-xs-3" style="width: 30%;">
                  <select name="coachId" class="form-control">
                    <option value=""></option>
                    <c:forEach var="coach" items="${empty siteId ? persist.coaches(currentPrincipal.id) : persist.coaches(currentPrincipal.id,siteId)}">
                      <option value="${empty siteId ? coach.id : coach.key}" ${(empty siteId ? coach.id : coach.key) == coachId ? 'selected' : ''}>${empty siteId ? coach.name : coach.value.name}</option>
                    </c:forEach>
                  </select>
                </div>
              </div>
              
              <div class="x-breadcrumb-wrapper clearfix" style="position: relative; margin-top: 15px;">
                <div class="btn-group pull-right">
                  <button id="search_btn" type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;
                </div>
              </div>
            </div>
          </form>

          <c:if test="${search}">
            <form class="form-horizontal" name="send_form" method="post" action="${ctx.host}/satisfaction-survey-create" data-validate="true" data-redirect="${ctx.host}/satisfaction-survey-create">
              <div id="grid-wrap" style="overflow-y:scroll;">
              <table class="table table-striped table-hover" style="margin-bottom:0;">
                  <thead>
                    <tr>
                      <th data-align="center" width=10%><input name="selectAll" type="checkbox" value="" />全选/全不选</th>
                      <th data-align="center" width=10%>门店</th>
                      <th data-align="center" width=15%>课程</th>
                      <th data-align="center" width=9%>学员姓名</th>
                      <th data-align="center" width=10%>学员手机号</th>
                      <th data-align="center" width=10%>主教练</th>
                      <th data-align="center" width=15%>最近一个月上课次数</th>
                      <th data-align="center" width=10%>课程开始时间</th>
                      <th data-align="center" width=11%>有效期截止时间</th>
                    </tr>
                  </thead>
              </table>
              </div>
              <div id="grid-wrap" style="min-height: 430px;height:300px;overflow-y:scroll;">
                <table class="table table-striped table-hover">
                  <tbody>
                    <c:forEach var="courseRound" items="${courseRounds}">
                      <tr>
                        <td width=10%><input name="courseRoundId" type="checkbox" value="${courseRound.courseRound.id}" /></td>
                        <td width=10%>${courseRound.courseRound.site.name}</td>
                        <td width=15%>${courseRound.courseRound.course.name}</td>
                        <td width=9%>${courseRound.courseRound.student.name}</td>
                        <td width=10%>${courseRound.courseRound.student.mobile}</td>
                        <td width=10%>${courseRound.courseRound.coach.name}</td>
                        <td width=15%>${courseRound.scheduleCount}</td>
                        <td width=10%><fmt:formatDate value="${courseRound.courseRound.effectiveStart}" pattern="yyyy-MM-dd"/></td>
                        <td width=11%><fmt:formatDate value="${courseRound.courseRound.effectiveEnd}" pattern="yyyy-MM-dd"/></td>
                      </tr>
                    </c:forEach>
                  </tbody>
                </table>
              </div>
              
              <div class="form-horizontal clearfix" style="padding-top: 10px;">
                <div class="form-group pull-left" style="width: 60%">
                  <label class="control-label col-xs-3">查询总计：</label>
                  <div class="col-xs-4" style="padding-left: 0px;">
                    <p class="form-control-static">${fn:length(courseRounds)}条记录</p>
                  </div>
                </div>
                <div class="btn-group pull-right">
                  <button id="send_btn" type="submit" style="width: 180px" class="btn btn-default btn-shadow btn-shadow-default x-btn">发送问卷</button>
                </div>
              </div>
            </form>
          </c:if>
        </div>
      </div>
    </div>
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>

  <d:resource root="${ctx.resource}/build" type="script" src="js/page/market/satisfaction-survey.js">
    <script type="text/javascript">
      require(['page/market/satisfaction-survey'],function(page){
        page.init();
      })
    </script>
  </d:resource>
</body>
</html>